package vip.denglei.company.service.app.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import vip.denglei.company.mapper.AppProductMapper;
import vip.denglei.company.model.app.AppProduct;
import vip.denglei.company.model.app.AppUserOrderDetails;
import vip.denglei.company.service.app.AppProductService;

import javax.annotation.Resource;
import java.util.List;

@Service
@Slf4j
public class AppProductServiceImpl extends ServiceImpl<AppProductMapper, AppProduct> implements AppProductService {
    @Resource
    private AppProductMapper appProductMapper;

    @Override
    public void modifyInventory(List<AppUserOrderDetails> appUserOrderDetailsList) {
        if(appUserOrderDetailsList.size()==0){
            return;
        }
        appUserOrderDetailsList.stream().forEach(appUserOrderDetails -> {
            appProductMapper.modifyInventory(appUserOrderDetails.getProId(), appUserOrderDetails.getProVolume());
        });
    }
}
